#ifndef _GENERICDAO_H_
#define _GENERICDAO_H_

#include "bd.h"
#define loadEntity(type,id) loadEntityById(getCurrentDAO(),#type,&type##I,id)
#define storeEntity(type,id) saveEntity(getCurrentDAO(),#type,&type##I,id)

typedef struct
{
  BDConnection *conn;
} GenericDAO;

GenericDAO *createDAO(BDConnection *connection);
void deleteDAO(GenericDAO *dao);

void *loadEntityById(GenericDAO *dao, char *tableName, void *iptr, char *id);
BDError saveEntity(GenericDAO *dao, char *tableName, void *iptr, void *obj);

void setCurrentDAO(GenericDAO *dao);
GenericDAO *getCurrentDAO();

#endif

